<template>
	<div>
		<div class="home">Welcome Home</div>
		<button @click="goToDashboard">goToDashboard</button>
		<button @click="jump">jump</button>
	</div>
</template>

<script>
	// Home.vue
	export default {
		computed: {
			username() {
				// 我们很快就会看到 `params` 是什么
				return this.$route.params.username;
			},
		},

		methods: {
			goToDashboard() {
				// if (isAuthenticated) {
				if (Math.random() > 0.5) {
					this.$router.push("/dashboard");
				} else {
					this.$router.push("/login");
				}
			},
			jump() {
				console.log("jump");
				this.$router.push({
					name: "NotFound",
					params: { pm: "user/admin/posts/123" },
				});
				console.log("jump end");
			},
		},
	};
</script>
